package com.example.demo.controller;


import com.example.demo.domain.test;
import com.example.demo.service.testService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class hello {

    @Autowired
    private testService testService;
    @RequestMapping("/hello")
    public String hello(){
        String s = testService.listall().toString();
        return s;
    }
    @RequestMapping("/{id}")
    public test select(@PathVariable int id){
        return testService.selectByid(id);
    }
    @RequestMapping("/like/{name}")
    public List<test> like(@PathVariable String name){
        return testService.selectBylike(name);
    }
    @DeleteMapping("/delete/{id}")
    public int delete(@PathVariable int id){
        return testService.delectByid(id);
    }
    @PostMapping("/insert")
    public void insert(test t1){
        this.testService.add(t1);
    }
    @PutMapping("/amend/{id}")
    public int amend(test t2){
        return testService.amendByid(t2);
    }
}
